@extends('admin.layout.layout')


     @section('content')   
            <div class="row">
                <div class="col-lg-12">
                    <h1 class="page-header">景点列表</h1>
                </div>
                <!-- /.col-lg-12 -->
            </div>

                  <div class="col-lg-12">
                    <div class="panel panel-default">
                        <!-- /.panel-heading -->
                  <div class="panel-body">
                            <div class="dataTable_wrapper">
                            <div id="dataTables-example_wrapper" class="dataTables_wrapper form-inline dt-bootstrap no-footer">
                            <div class="row">
                            <form action="{{url('/admin/scenic/list')}}" mothed="get">
                            <div class="col-sm-6"><div class="dataTables_length" id="dataTables-example_length">
                     <label>显示
                              <select name="num" aria-controls="dataTables-example" class="form-control input-sm">
                                    <option value="10" @if(!empty($request['num']) && $request['num'] == 5) { selected } @endif>5</option>
                                    <option value="25" @if(!empty($request['num']) && $request['num'] == 6) { selected } @endif>6</option>
                                    <option value="50"  @if(!empty($request['num']) && $request['num'] == 7) { selected } @endif>7</option>
                                    <option value="100"  @if(!empty($request['num']) && $request['num'] == 8) { selected } @endif>8</option>
                              </select> 条
                     </label>
                           </div>
                          </div>
                          <div class="col-sm-6">
                           <div id="dataTables-example_filter" class="dataTables_filter">
                            <label>景点名:

                                <input name="keywords" value="@if(!empty($request['keywords'])){{$request['keywords']}}@endif" type="search" class="form-control input-sm" placeholder="" aria-controls="dataTables-example" />
                            </label>
                            <button class="btn btn-info" type="submit">查询</button>
                           </div>
                          </div>
                          </form>
                           </div>


                                 <div class="row"><div class="col-sm-12">
                                 <table class="table table-striped table-bordered table-hover dataTable no-footer" id="dataTables-example" role="grid" aria-describedby="dataTables-example_info">
                                    <thead>
                                        <tr role="row">
                                        <th class="sorting_asc" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" aria-sort="ascending" aria-label="Rendering engine: activate to sort column descending" style="width: 50px;">序号</th>
                                        <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending" style="width: 107px;">景点名称</th>
                                        <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" aria-label="Platform(s): activate to sort column ascending" style="width: 188px;">景点简介</th>
                                        <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" aria-label="Engine version: activate to sort column ascending" style="width: 147px;">地址</th>
                                        <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" aria-label="Engine version: activate to sort column ascending" style="width: 200px;">开放时间</th>
                                        <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" aria-label="Engine version: activate to sort column ascending" style="width: 80px;">服务保障</th>
                                        <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" aria-label="Engine version: activate to sort column ascending" style="width: 50px;">门票</th>
                                        <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" aria-label="Engine version: activate to sort column ascending" style="width: 50px;">原价</th>

                                        <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" aria-label="CSS grade: activate to sort column ascending" style="width: 108px;">操作</th>
                                        </tr>
                                    </thead>
                                    <tbody>    
                                    @foreach($scenic as $k => $v)                               
                                    <tr class="gradeA odd" role="row">
                                            <td class="sorting_1 sid">{{$v->id}}</td>
                                            <td>{{$v->name}}</td>
                                            <td>{{$v->description}}</td>
                                            <td>{{$v->address}}</td>
                                            <td>{{$v->ktime}}</td>
                                            <td class="center">{{$v->server}}</td>
                                            <td class="center">{{$v->price}}</td>
                                            <td>{{$v->oldprice}}</td>

                                             
                                            <td class="center">
                                                <a href="" class="fa fa-trash-o delete">删除</a>
                                                |
                                                <a href="{{url('/admin/scenic/edit',['id'=>$v->id])}}" class="fa fa-wrench">修改</a>
                                            </td>
                                        </tr>
                                    @endforeach
                                   </tbody>
                                </table>
                                </div>
                                </div>
                                <div class="row">

                                <div class="col-sm-6 col-sm-offset-3">
                                <div class="dataTables_paginate paging_simple_numbers" id="dataTables-example_paginate">
                                {!! $scenic->render() !!}
                                </div></div></div></div>
                            </div>                            
                        </div>
                        <!-- /.panel-body -->
                    </div>
                    <!-- /.panel -->
                </div>
    @endsection

  @section('myjs')
    <script type="text/javascript">
    $.ajaxSetup({
        headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        }
    });
       $('.delete').click(function(){
            
           var id = $(this).parents('tr').find('.sid').html();
           var dd = $(this);
            $.get('/admin/scenic/delete',{id:id},function(data){

              if(data ==1 ){
                 dd.parents('tr').remove();
              }else{
                alert('失败');
              }
            })
           return  false;
       })

       
    </script>
  @endsection